cmake_minimum_required(VERSION 3.20)
project(amalgam LANGUAGES C CXX)

## Set CMake default behavoir
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Generate compile_commands.json
set(CMAKE_CXX_STANDARD 17) # Set C++ standard to 17
set(CMAKE_CXX_STANDARD_REQUIRED ON) # Set C++ standard as required
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") # Place static libs in lib/
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") # Place shared libs in lib/
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") # Place programs in bin/
set(CMAKE_UNITY_BUILD ON) # https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html
set(UNITY_BUILD_MODE BATCH) # Automatically guess how to group files
set(UNITY_BUILD_BATCH_SIZE 10) # How intense should the unifying build be

## Add options to CMake
option(WITH_TESTS "Compile with tests" ON)
option(BACKEND "Which render backend should be used" "opengl")
set(BACKEND "opengl") # For some reason setting a default doesn't work?

find_package(GLEW REQUIRED)
find_package(glfw3 REQUIRED)

## Add primary project to build
if(BACKEND STREQUAL "opengl")
    add_subdirectory(src/backends/opengl)
endif()
add_subdirectory(src/app)

## Define custom commands
add_custom_target(tarball COMMAND ${CMAKE_CURRENT_LIST_DIR}/scripts/tarball.sh)
#add_custom_target(clean COMMAND ${CMAKE_CURRENT_LIST_DIR}/scripts/clean.sh)
